﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class clsDinhNghiaCanDoiKeToan
    {
        private int mCachTinh = 0;
        private string mDienGiai = "";
        private int mGhiAm = 0;
        private int mHienThi = 0;
        private string mLoai = "";
        private string mLoaiTinh = "";
        private string mMaSo = "";
        private string mNguon = "";
        private string mStt = "";
        private string mThuyetMinh = "";
        private string mVe = "";

        public object GetList()
        {
            string commandText = " SELECT * FROM HT_DinhNghiaCanDoiKeToan ORDER BY Stt ";
            return DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
        }

        public bool Load(string pMaSo)
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[2];
            try
            {
                string commandText = "SELECT * FROM HT_DinhNghiaCanDoiKeToan WHERE MaSo = '" + pMaSo + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, commandParameters);
                if (dataReader.Read())
                {
                    this.mStt = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mLoai = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mDienGiai = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mMaSo = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mThuyetMinh = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mHienThi = Conversions.ToInteger(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetInt32));
                    this.mVe = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mLoaiTinh = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mCachTinh = Conversions.ToInteger(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetInt32));
                    this.mNguon = Conversions.ToString(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetString));
                    this.mGhiAm = Conversions.ToInteger(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save(string pMaSoBanDau = "")
        {
            bool flag2;
            if (pMaSoBanDau.Trim() == "")
            {
                pMaSoBanDau = this.mMaSo;
            }
            IDataParameter[] commandParameters = new IDataParameter[12];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@MaSoBanDau", DbType.Int64, ParameterDirection.Input, pMaSoBanDau);
                commandParameters[1] = DBHelper.createParameter("@Stt", DbType.Int64, ParameterDirection.Input, this.mStt);
                commandParameters[2] = DBHelper.createParameter("@Loai", DbType.Int64, ParameterDirection.Input, this.mLoai);
                commandParameters[3] = DBHelper.createParameter("@DienGiai", DbType.Int64, ParameterDirection.Input, this.mDienGiai);
                commandParameters[4] = DBHelper.createParameter("@MaSo", DbType.Int64, ParameterDirection.Input, this.mMaSo);
                commandParameters[5] = DBHelper.createParameter("@ThuyetMinh", DbType.Int64, ParameterDirection.Input, this.mThuyetMinh);
                commandParameters[6] = DBHelper.createParameter("@HienThi", DbType.Double, ParameterDirection.Input, this.mHienThi);
                commandParameters[7] = DBHelper.createParameter("@Ve", DbType.Int64, ParameterDirection.Input, this.mVe);
                commandParameters[8] = DBHelper.createParameter("@LoaiTinh", DbType.Int64, ParameterDirection.Input, this.mLoaiTinh);
                commandParameters[9] = DBHelper.createParameter("@CachTinh", DbType.Double, ParameterDirection.Input, this.mCachTinh);
                commandParameters[10] = DBHelper.createParameter("@Nguon", DbType.Int64, ParameterDirection.Input, this.mNguon);
                commandParameters[11] = DBHelper.createParameter("@GhiAm", DbType.Double, ParameterDirection.Input, this.mGhiAm);
                bool flag = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "HT_sp_DinhNghiaCanDoiKeToan", commandParameters) > 0;
                flag2 = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag2 = false;
                ProjectData.ClearProjectError();
                return flag2;
                ProjectData.ClearProjectError();
            }
            return flag2;
        }

        public int CachTinh
        {
            get
            {
                return this.mCachTinh;
            }
            set
            {
                this.mCachTinh = value;
            }
        }

        public string DienGiai
        {
            get
            {
                return this.mDienGiai;
            }
            set
            {
                this.mDienGiai = value;
            }
        }

        public int GhiAm
        {
            get
            {
                return this.mGhiAm;
            }
            set
            {
                this.mGhiAm = value;
            }
        }

        public int HienThi
        {
            get
            {
                return this.mHienThi;
            }
            set
            {
                this.mHienThi = value;
            }
        }

        public string Loai
        {
            get
            {
                return this.mLoai;
            }
            set
            {
                this.mLoai = value;
            }
        }

        public string LoaiTinh
        {
            get
            {
                return this.mLoaiTinh;
            }
            set
            {
                this.mLoaiTinh = value;
            }
        }

        public string MaSo
        {
            get
            {
                return this.mMaSo;
            }
            set
            {
                this.mMaSo = value;
            }
        }

        public string Nguon
        {
            get
            {
                return this.mNguon;
            }
            set
            {
                this.mNguon = value;
            }
        }

        public string Stt
        {
            get
            {
                return this.mStt;
            }
            set
            {
                this.mStt = value;
            }
        }

        public string ThuyetMinh
        {
            get
            {
                return this.mThuyetMinh;
            }
            set
            {
                this.mThuyetMinh = value;
            }
        }

        public string Ve
        {
            get
            {
                return this.mVe;
            }
            set
            {
                this.mVe = value;
            }
        }
    }
}

